package edu.sctu.wulixia.month6.day20150616;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by user05 on 2015/6/16.
 */
public class UrlConnection {
    public void getUrlConnection(String path) throws IOException {

        URL url = new URL(path);
        HttpURLConnection connection = ( HttpURLConnection)url.openConnection();
        InputStream inputStream = connection.getInputStream();
        byte[] buffer = new byte[inputStream.available()];
        int count ;

        while((count = inputStream.read(buffer)) != -1){
            System.out.println(new String(buffer,0,count));
        }
        inputStream.close();
    }
}
